/*
 * @Author: 陈德基
 * @Date: 2021-11-15 15:45:08
 * @LastEditTime: 2021-11-18 09:30:00
 * @Description: 
 * @FilePath: \copy_gsy_github_app_flutter\lib\page\main\widgets\main.dart
 * 联系方式：
 * wx: melody_2009
 * qq: 7815171323 
 */
import 'package:copy_gsy_github_app_flutter/common/style/gsy_style.dart';
import 'package:copy_gsy_github_app_flutter/page/main/subpage/dynamic.dart';
import 'package:copy_gsy_github_app_flutter/page/main/subpage/mine.dart';
import 'package:copy_gsy_github_app_flutter/page/main/subpage/trend.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';

import 'base_index_with_pages_state.dart';

/// hello
// ignore: must_be_immutable
class MainWidget extends BaseIndexPageWithChildPagesWidget {
  MainWidget()
      : super(
            appBar: AppBar(
              title: Text('app_name'.tr),
            ),
            selectedLabelStyle: TextStyle(
                color: Color.fromARGB(255, 30, 28, 29), fontSize: 20.sp),
            unSelectedLabelStyle: TextStyle(
                color: Color.fromARGB(255, 103, 103, 103), fontSize: 20.sp),
            callback: (i) {
              switch (i) {
                case 3:
                  // 更新用户的信息
                  // var userControlelr = Get.find<UserInfoController>();
                  // userControlelr.getUserCenterInfo();
                  break;
              }
            });

  @override
  Widget buildIndexPage() {
    return super.buildIndexPage();
  }

  var mainChildPages = [DynamicWidget(), TrendWidget(), MineWidget()];
  var titles = [
    'index'.tr, 'trend'.tr,
    //  'show'.tr,
    'mine'.tr,
  ];

  static const _icons = [AppICons.MAIN_DT, AppICons.MAIN_QS, AppICons.MAIN_MY];

  @override
  barItems() {
    return List.generate(titles.length, (index) {
      // var normalIcon = svgIcons[index]['normal'];
      // var selectedIcon = svgIcons[index]['selected'];
      return BottomNavigationBarItem(
          icon: new Icon(_icons[index], size: 16.0),
          title: Container(
            child: Text(
              titles[index],
              style: APPFont.smallText,
            ),
          ));
    });
  }

  @override
  clickAgainExit() {
    Fluttertoast.showToast(msg: 'click_back_again_exit_app'.tr);
  }

  @override
  itemCount() {
    return titles.length;
  }

  @override
  pageBuild(BuildContext context, int index) {
    return mainChildPages[index];
  }
}
